﻿using System;

namespace AstrologicalDigits
{
    class AstrologicalDigits
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            n = Math.Abs(n);
            int sum = 0;
            int m = 0;

            while (n != 0)
            {
                sum += n % 10;
                n /= 10;
            }

            if (sum > 9)
            {
                m = sum;
                sum = 0;
                while (m != 0)
                {
                    sum += m % 10;
                    m /= 10;
                }
            } 
            Console.WriteLine(sum);
        }
    }
}
